
<?php
/**
 * Registration Form
 * This form would allow users of the system register with the system
 * 
 */

 class Account_Form_Register extends Zend_Dojo_Form
 {
	public function __construct($options = null)
		{
		parent::__construct($options);
		Zend_Dojo::enableForm($this);
		$this->setName('Register');
		$id = new Zend_Form_Element_Hidden('id');
		$id->addFilter('int');
		
		$this->addElement($id);
		//User enters his First Name
		$firstName = new Zend_Dojo_Form_Element_ValidationTextBox('fname');
		$firstName->setLabel('FirstName')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->setpromptMessage('Please enter your first name')
		->addValidator('NotEmpty');
		
		$LastName = new Zend_Dojo_Form_Element_ValidationTextBox('lname');
		$LastName->setLabel('LastName')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty')
		->setpromptMessage('Please enter your last name')
		->addErrorMessage("Please input your last name");
		
    
    	//Last Name --Dojo
	$validator = new Zend_Validate_EmailAddress(
					Zend_Validate_Hostname::ALLOW_DNS,
					true);
	
					
  // $validator->getHostnameValidator()->
		
	//This sets the min and max lengths of user inputs.
	$newVad = new Zend_Validate_StringLength();
	$newVad->setMax(15);
	$newVad->setMin(6);
	
	//$range = new Zend_Validate_Between(1, 100);
	
		//User Enters email address
		$emailaddress = new Zend_Dojo_Form_Element_ValidationTextBox('email');
		$emailaddress->setLabel('Email: ')
					 ->setRequired(true)
					 ->addFilter('StripTags')
					 ->addFilter('StringTrim')
					 ->setpromptMessage('Please enter your email address')
					 ->addValidator('NotEmpty')
					 ->addValidator($validator);
					 
		/**
		 * User Account details
		 */
		$userName = new Zend_Dojo_Form_Element_ValidationTextBox('username');
		$userName->setLabel('UserName: ')
					 ->setRequired(true)
					 ->addFilter('StripTags')
					 ->addFilter('StringTrim')
					 ->setpromptMessage('Please enter your username of at least six characters')
					 ->addValidator($newVad)
					 ->addValidator('NotEmpty');
		
		$password = new Zend_Dojo_Form_Element_PasswordTextBox('password');
		$password->setLabel('Password: ')
					 ->setRequired(true)
					 ->setpromptMessage('Please enter your password')
					 ->addValidator('NotEmpty');	
		

$combo = new Zend_Dojo_Form_Element_FilteringSelect('box');
		//Select school

$options = (array ("University of Maine" => "University of Maine", 
					"University of New Hampshire" => "University of New Hampshire", 
					"University of Vermont" => "University of Vermont",
					"University of Arizona" => "University of Arizona",
					"University of Conneticut" => "University of Conneticut",
					"University of Colorado at Boulder" => "University of Colorado at Boulder",
					"Arizona State University" => "Arizona State University"));
$school = new Zend_Dojo_Form_Element_FilteringSelect('school');
$school->setLabel('Select school');
$school->addMultiOptions($options);
$school->setAutocomplete(true);

$pubKey = "6LfYhQsAAAAAAB_0Tfli3hzQdE0WF6YgGyY-dScs"; 
$privKey = "6LfYhQsAAAAAAJs_fWcMv1vUS8zdNKD0WUNo2nCO"; 
$recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey);
$captcha = new Zend_Form_Element_Captcha('challenge',array('captcha'        => 'ReCaptcha',
               'captchaOptions' => array('captcha' => 'ReCaptcha', 'service' => $recaptcha)));		   
		$submit = new Zend_Dojo_Form_Element_SubmitButton('submit');
		$submit->setLabel('Register');
		
		$this->addElements(array($emailaddress,$school, $userName, $password, $captcha) );
	    $this->addElement($submit);
	    
		//$this->setAction('register');
$userName->removeDecorator('Label');
$userName->addDecorator('Label');
$userName->removeDecorator('HtmlTag');
$userName->addDecorator('HtmlTag', array('tag' => 'p'));

//Password styling

$password->removeDecorator('Label');
$password->addDecorator('Label');
$password->removeDecorator('HtmlTag');
$password->addDecorator('HtmlTag', array('tag' => 'p'));

//First Name styling
$firstName->removeDecorator('Label');
$firstName->addDecorator('Label');
$firstName->removeDecorator('HtmlTag');
$firstName->addDecorator('HtmlTag', array('tag' => 'p'));

//Last Name styling
$LastName->removeDecorator('Label');
$LastName->addDecorator('Label');
$LastName->removeDecorator('HtmlTag');
$LastName->addDecorator('HtmlTag', array('tag' => 'p'));

//Email styling
$emailaddress->removeDecorator('Label');
$emailaddress->addDecorator('Label');
$emailaddress->removeDecorator('HtmlTag');
$emailaddress->addDecorator('HtmlTag', array('tag' => 'p'));

//School styling
$school->removeDecorator('Label');
$school->addDecorator('Label');
$school->removeDecorator('HtmlTag');
$school->addDecorator('HtmlTag', array('tag' => 'p'));

//Removing dl tag to be replaced by a fieldset
$this->setDecorators(array(
          'FormElements',
          array('HtmlTag', array('tag' => 'fieldset')),
          'Form'
      ));
 
		$this->setMethod('POST');
		}
}
 
